#ifndef RTPPARSE_WEBRTC_SERVER_H
#define RTPPARSE_WEBRTC_SERVER_H

#include "UdpSocket.h"
#include <string>
#include <vector>
#include <map>

class TransportTuple;
class WebRtcTransport;
class WebRtcServer: public UdpSocket::Listener {
public:
    struct UdpSocketOrTcpServer {
        UdpSocketOrTcpServer(UdpSocket *udpSocket, 
                            std::string& announcedAddress,
                            bool exposeInternalIp){}

        UdpSocket *udpSocket;
        std::string announceAddress;
        bool exposeInternalIp;
    };

public:
    WebRtcServer(const std::string& id);
    ~WebRtcServer() override;

public:
    void OnUdpSocketPacketReceived(UdpSocket *socket, const uint8_t* data, size_t len,
                                           const struct sockaddr* addr) override;

private:
    void OnPacketReceived(TransportTuple *tuple, const uint8_t* data, size_t len);
    void OnNonStunDataReceived(TransportTuple *tuple, const uint8_t* data, size_t len);
public:
    const std::string id;

private:
    std::vector<UdpSocketOrTcpServer> udpSocketOrTcpServers;
    std::map<uint16_t, WebRtcTransport *> mapTupleWebRtcTransport;
    bool closing { false };
};

#endif